package com.powernode.config;

import com.powernode.constant.Constants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {

    @Bean
    public DirectExchange seckillExchange(){
        return new DirectExchange(Constants.EXCHANGE_NAME_ORDER);
    }

    @Bean
    public Queue seckillQueue(){
        return new Queue(Constants.QUEUE_NAME_ORDER);
    }

    @Bean
    public Binding binding(){
        return BindingBuilder.bind(seckillQueue()).to(seckillExchange()).with(Constants.ROUTING_KEY_ORDER);
    }
}
